package lu.med.praxiswahl.wahlumed.client.utilities;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;

import lu.med.praxiswahl.wahlumed.client.wclient.Main;


public class BitmapViewer extends JDialog implements ActionListener
{
    /**
     * 
     */
    private static final long serialVersionUID = 7635906779328350555L;
    private BitmapViewerListener owner;

    public BitmapViewer(Main dataManager, Image img, BitmapViewerListener owner)
    {
	super(dataManager, "Bild Vorschau nach Scan Vorgang", true);
	this.setLayout(new BorderLayout());
	this.owner = owner;
	JPanel bp = new JPanel(new GridLayout(1, 0));
	JButton b1, b2;
	b1 = new JButton("Speichern");
	b2 = new JButton("Verwerfen");
	b1.addActionListener(this);
	b2.addActionListener(this);
	bp.add(b1);
	bp.add(b2);
	this.add(bp, BorderLayout.SOUTH);
	this.add(new ImagePanel(img), BorderLayout.CENTER);
    }

    @Override
    public void actionPerformed(ActionEvent e)
    {
	if (e.getActionCommand().equals("Speichern"))
	{
	    owner.getSaveStatus(true);
	}
	else
	{
	    owner.getSaveStatus(false);
	}
	this.setVisible(false);
    }
}
